package tech.aistar.corejava.day10.dat10work.Test10;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by 豆梦寒 on 2019/7/27.
 */
public class Test10 {
    public static void main(String[] args) {
        String a="x894240083444";
        List<String> b = new ArrayList<String>();
        Pattern p = Pattern.compile("[^0-9]");
        Matcher m = p.matcher(a);
        String result = m.replaceAll("");
        int sum=0;
        int sum1=0;
        int sum2;
        int amass;
        int x;
        for (int i = 0; i < result.length(); i++) {
            String str = result.substring(i,i+1);
            try {
                int c = Integer.parseInt(str);
                if (c%2==1) {
                    sum=c+sum;
                }else if(c%2==0){
                    sum1=c+sum1;
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
        }
        amass=3*sum;
        sum2=amass+sum1;
        x=((sum2/10)+1)*10-sum2;
//        System.out.println(sum);
//
//        System.out.println(amass);
//
//        System.out.println(sum1);
//
//        System.out.println(sum2);
        System.out.println("x="+x);
    }
}

